package com.qut.system_1.controller;

import com.qut.system_1.mapper.RegisterMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

//表示spring框架自动创建对象
@RestController
@RequestMapping("/register")
public class RegisterController {

    //依赖注入IoC
    @Resource
    private RegisterMapper registerMapper;
    @RequestMapping("/add")
    public int add(@RequestParam Map<String,String> param){
        int row=0;
        System.out.println(param);
        //调用接口中的方法
        row=registerMapper.add1(param);
        return row;
    }
    //可变长度数组
    //Map集合存放每一行中的数据
    //以列名为key,数据为value
    //useId  userName  userSex
    // 1      张三       2
    //map.put("userId",1)
    //map.put("useName",张三)
    //map.put("userSex",2)
    //@return
    @RequestMapping("/search")
    public List<Map<String,Object>> search(@RequestParam Map<String,String> param) {
        List<Map<String, Object>> list = null;
        list = registerMapper.search(param);
        return list;
    }
    @RequestMapping("/edit")
    public int edit(@RequestParam Map<String,String> param){
            int row=0;
            row=registerMapper.update(param);
            return row;
        }
    @RequestMapping("/delete")
    public int batchDelete(String[] ids){
        int row=0;
        row=registerMapper.batchDelete(ids);
        return row;
    }
}
